home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1997 September & October / Amiga-CD 1997 #9-10.iso / aminet / gameboyemulator / gb.h < prev    next >
C/C++ Source or Header  |  1995-10-29  |  7KB  |  165 lines

  1. /** VGB: portable GameBoy emulator ***************************/
  2. /**                                                         **/
  3. /**                           GB.h                          **/
  4. /**                                                         **/
  5. /** This file contains definitions for the GameBoy hardware **/
  6. /** emulation.                                              **/
  7. /**                                                         **/
  8. /** Copyright (C) Marat Fayzullin 1995                      **/
  9. /**     You are not allowed to distribute this software     **/
  10. /**     commercially. Please, notify me, if you make any    **/   
  11. /**     changes to this file.                               **/
  12. /*************************************************************/
  13.  
  14.  
  15. /* Amiga includes */
  16. #include <proto/exec.h>
  17. #include <proto/dos.h>
  18. #include <proto/intuition.h>
  19. #include <proto/graphics.h>
  20. #include <proto/asl.h>
  21. #include <dos/rdargs.h>
  22. #include <exec/memory.h>
  23. #include <devices/audio.h>
  24.  
  25. #include "Z80.h"
  26.  
  27. #define NORAM     0xFF
  28. #define MAXCHEAT  256
  29.  
  30. #define VBL_IFLAG 0x01
  31. #define LCD_IFLAG 0x02
  32. #define TIM_IFLAG 0x04
  33. #define SIO_IFLAG 0x08
  34. #define JOY_IFLAG 0x10
  35.  
  36. #define JOYPAD  RAM[0xFF00] /* Joystick: 1.1.P15.P14.P13.P12.P11.P10      */
  37. #define SIODATA RAM[0xFF01] /* Serial IO data buffer                      */
  38. #define SIOCONT RAM[0xFF02] /* Serial IO control register                 */
  39. #define DIVREG  RAM[0xFF04] /* Divider register (???)                     */
  40. #define TIMECNT RAM[0xFF05] /* Timer counter. Gen. int. when it overflows */
  41. #define TIMEMOD RAM[0xFF06] /* New value of TimeCount after it overflows  */
  42. #define TIMEFRQ RAM[0xFF07] /* Timer frequency and start/stop switch      */
  43. #define IFLAGS  RAM[0xFF0F] /* Interrupt flags: 0.0.0.JST.SIO.TIM.LCD.VBL */
  44. #define ISWITCH RAM[0xFFFF] /* Switches to enable/disable interrupts      */
  45. #define LCDCONT RAM[0xFF40] /* LCD control register                       */
  46. #define LCDSTAT RAM[0xFF41] /* LCD status register                        */
  47. #define SCROLLY RAM[0xFF42] /* Starting Y position of the background      */
  48. #define SCROLLX RAM[0xFF43] /* Starting X position of the background      */
  49. #define CURLINE RAM[0xFF44] /* Current screen line being scanned          */
  50. #define CMPLINE RAM[0xFF45] /* Gen. int. when scan reaches this line      */
  51. #define BGRDPAL RAM[0xFF47] /* Background palette                         */
  52. #define SPR0PAL RAM[0xFF48] /* Sprite palette #0                          */
  53. #define SPR1PAL RAM[0xFF49] /* Sprite palette #1                          */
  54. #define WNDPOSY RAM[0xFF4A] /* Window Y position                          */
  55. #define WNDPOSX RAM[0xFF4B] /* Window X position                          */
  56. #define SNDREG10 RAM[0xFF10]
  57. #define SNDREG11 RAM[0xFF11]
  58. #define SNDREG12 RAM[0xFF12]
  59. #define SNDREG13 RAM[0xFF13]
  60. #define SNDREG14 RAM[0xFF14]
  61. #define SNDREG21 RAM[0xFF16]
  62. #define SNDREG22 RAM[0xFF17]
  63. #define SNDREG23 RAM[0xFF18]
  64. #define SNDREG24 RAM[0xFF19]
  65. #define SNDREG30 RAM[0xFF1A]
  66. #define SNDREG31 RAM[0xFF1B]
  67. #define SNDREG32 RAM[0xFF1C]
  68. #define SNDREG33 RAM[0xFF1D]
  69. #define SNDREG34 RAM[0xFF1E]
  70. #define SNDREG41 RAM[0xFF20]
  71. #define SNDREG42 RAM[0xFF21]
  72. #define SNDREG43 RAM[0xFF22]
  73. #define SNDREG44 RAM[0xFF23]
  74. #define SNDREG50 RAM[0xFF24]
  75. #define SNDREG51 RAM[0xFF25]
  76. #define SNDREG52 RAM[0xFF26]
  77.  
  78. extern byte Verbose;          /* Verboseness level                          */
  79.  
  80. extern byte *RAM;             /* Pointer to Z80 address space (64kB)        */
  81.  
  82. extern int  UPeriod;          /* Number of VBlanks per screen update        */
  83. extern int  VPeriod;          /* Number of Z80 cycles between VBlanks       */
  84.  
  85. extern byte LineDelay;        /* When 1, CMPLINE interrupts are delayed     */
  86.  
  87. extern int  ROMBanks;         /* Total number of ROM banks                  */ 
  88. extern int  RAMBanks;         /* Total number of RAM banks                  */
  89.  
  90. extern byte BPal[4];          /* Background palette                         */
  91. extern byte SPal0[4],SPal1[4];/* Sprite palettes                            */
  92.  
  93. extern byte *ChrGen;          /* Character generator                        */
  94. extern byte *BgdTab,*WndTab;  /* Background and window character tables     */
  95.  
  96.  
  97. void M_WRMEM(word A,byte V);
  98.  
  99.  
  100. /****************************************************************/
  101. /*** Initialize and start GameBoy emulation. This function    ***/
  102. /*** returns 0 in the case of failure.                        ***/
  103. /****************************************************************/
  104. int StartGB(char *CartName);
  105.  
  106. /****************************************************************/
  107. /*** Free resources allocated by StartGB().                   ***/
  108. /****************************************************************/
  109. void TrashGB(void);
  110.  
  111. /****************************************************************/
  112. /*** Add a cheat to the cheat list [call before StartGB()].   ***/
  113. /****************************************************************/
  114. int AddCheat(char *Cheat);
  115.  
  116. /****************************************************************/
  117. /*** Allocate resources needed by the machine-dependent code. ***/
  118. /************************************** TO BE WRITTEN BY USER ***/
  119. int InitMachine(void);
  120.  
  121. /****************************************************************/
  122. /*** Deallocate all resources taken by InitMachine().         ***/
  123. /************************************** TO BE WRITTEN BY USER ***/
  124. void TrashMachine(void);
  125.  
  126. /****************************************************************/
  127. /*** Refresh screen.                                          ***/
  128. /************************************** TO BE WRITTEN BY USER ***/
  129. void RefreshScreen(void);
  130.  
  131. /****************************************************************/
  132. /*** Refresh line Y [0-143].                                  ***/
  133. /************************************** TO BE WRITTEN BY USER ***/
  134. void RefreshLine(byte Y);
  135.  
  136. /****************************************************************/
  137. /*** Refresh sprites.                                         ***/
  138. /************************************** TO BE WRITTEN BY USER ***/
  139. void RefreshSprites(void);
  140.  
  141. /****************************************************************/
  142. /*** Get joystick state: START.SELECT.B.A.D.U.L.R.            ***/
  143. /************************************** TO BE WRITTEN BY USER ***/
  144. byte Joystick(void);
  145.  
  146. /****************************************************************/
  147. /*** Amiga specific functions and defines                     ***/
  148. /************************************** TO BE WRITTEN BY USER ***/
  149. STRPTR ReqFile(void);
  150. void __inline AllocatePens(void);
  151. extern void __asm StartDisplay(register __d0 byte Y);
  152. BOOL __inline InitSound(void);
  153. void __inline FreeSound(void);
  154. struct IOAudio *NewIOBlock(UBYTE*);
  155. void FreeIOBlock(struct IOAudio*);
  156. void __inline PlaySound(void);
  157. void __inline PlaySample(UBYTE*, UWORD, UWORD, UBYTE, UBYTE);
  158.  
  159. #define OPT_VERBOSE ((ULONG*)(ArgPtrs[0]))
  160. #define OPT_VPER ((ULONG*)(ArgPtrs[1]))
  161. #define OPT_UPER ((ULONG*)(ArgPtrs[2]))
  162. #define OPT_TRAP ((STRPTR)(ArgPtrs[3]))
  163. #define OPT_HELP ((BOOL)(ArgPtrs[4]))
  164. #define OPT_SCALEUP ((BOOL)(ArgPtrs[5]))
  165.